<template>
  <div class="evaluate__item" :class="itemClass">
    <div class="people__info">
      <div class="left">
        <img :src="detail.avatar" />
      </div>
      <div class="right">
        <div class="name__info">
          <span class="name">{{ detail.name }}</span>
          <div class="time">{{ detail.time }}</div>
        </div>
        <div class="start__area">
          <van-rate :size="12" :count="detail.startNumber" color="#ffd21e" void-icon="star" void-color="#FFCA2C" />
        </div>
      </div>
    </div>
    <div class="memo" v-show="detail.memo">{{ detail.memo }}</div>
  </div>
</template>

<script lang="ts">
import { defineComponent, PropType, ref } from 'vue'
import { Rate } from 'vant'
import { EvaluateItemType } from '../utils/types'

export default defineComponent({
  name: 'EvaluateItem',
  props: {
    showBtBorder: {
      type: Boolean,
      default: () => false
    },
    detail: {
      type: Object as PropType<EvaluateItemType>,
      default: () => {
        return {
          startNumber: 0
        }
      }
    }
  },
  components: {
    'van-rate': Rate
  },
  setup(props) {
    const itemClass = ref<string>('')
    if (props.showBtBorder) {
      itemClass.value += 'evaluate__item__bt_border'
    }
    return {
      itemClass
    }
  }
})
</script>

<style lang="scss" scoped>
@import '@/style/variables.scss';
@import '@/style/mixins.scss';
.evaluate__item {
  &__bt_border {
    border-bottom: 1px solid #ededed;
    padding-bottom: 15px;
  }
  .item {
    .memo {
      font-size: 12px;
      font-weight: 400;
      color: #101736;
      line-height: 20px;
    }
  }

  .people__info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0 0 0;
    .left {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      overflow: hidden;
      box-shadow: 0px 2px 8px 0px rgba(192, 196, 201, 0.48);
      img {
        width: 100%;
      }
    }
    .right {
      width: calc(100% - 40px);
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .name__info {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
      }
      .name {
        font-size: 14px;
        font-weight: 500;
        color: #101736;
        line-height: 16px;
        width: calc(100% - 120px);
        @include ellipsis;
      }
      .time {
        width: 120px;
        font-size: 12px;
        font-weight: 400;
        color: #575c72;
        line-height: 17px;
        text-align: right;
      }
    }
  }
  .memo {
    padding: 15px 0 0 0;
    line-height: 20px;
  }
}
</style>
